<template>
  <div class="enterbox">
    <div class="topbox" @click.stop="hidelogin">
          <i class="iconfont icon-guanbi"></i>
        </div>
    <div class="title">手机号登录</div>

    <div class="content">
      <div class="one">登录体验更多精彩</div>
      <div class="two">未注册手机号登录后将自动创建账号</div>
      <div class="three">
        +86
        <input type="text" placeholder="请输入手机号" v-model="phone" />
      </div>
      <div :class="{'can':can,'next':true}" @click.stop="judge">下一步</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      phone: "",
      can: false,
    };
  },
  methods: {
    hidelogin() {
      this.$emit("hidelogson");
    },
    judge() {
      if (this.phone == "") {
        return;
      }
      let reg = new RegExp(
        /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/
      );
      if (!reg.test(this.phone)) {
        this.$toast("手机号应该是11位数字");
      } else {
        this.$emit("change-enter-codeson", this.phone);
      }
    },
  },
  watch: {
    phone(newV) {
      if (newV != "") {
        this.can = true;
      } else {
        this.can = false;
      }
    },
  },
};
</script>

<style lang="less">
.enterbox {
  z-index: 2001;
  position: fixed;
  background-color: white;
  padding: 60px 15px;
  height: 100%;
  left: 0;
  width: 100%;
  top: 0;
  box-sizing: border-box;
  i{
    &.icon-guanbi{
      font-size: 24px;
    }
  }
  .title{
    margin-top: 20px;
    font-size: 20px;
  }
  div {
    &.one {
      margin-top: 8%;
      font-size: 18px;
    }
    &.two {
      margin-top: 4%;
      font-size: 14px;
      font-weight: lighter;
    }
    &.three {
      margin-top: 7%;
      font-size: 18px;
      font-weight: lighter;
      border-bottom: 1px solid rgba(0, 0, 0, 0.2);
      padding-bottom: 11px;
      input {
        border: none;
      }
    }
    &.next {
      margin-top: 10%;
      font-size: 18px;
      background-color: #c73e2c7a;
      color: white;
      height: 40px;
      line-height: 40px;
      text-align: center;
      border-radius: 100px;
      &.can {
        background-color: #c73e2c;
      }
    }
  }
}
</style>